package com.hb.study.design_patterns.prototype;

import java.util.ArrayList;
import java.util.List;

/**
 * 原型模式
 *
 * @author Mr.Huang
 * @version v0.1, PrototypeModel.java, 2020/5/15 13:59, create by huangbiao.
 */
public class PrototypeModel implements Cloneable {

    private int age;

    private List<String> arrayList = new ArrayList<>();

    public PrototypeModel(int age) {
        System.out.println("执行了构造方法");
        this.age = age;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public void addValue(String e) {
        this.arrayList.add(e);
    }

    @Override
    public String toString() {
        return "PrototypeModel{" +
                "age=" + age +
                ", arrayList=" + arrayList +
                '}';
    }

    @Override
    protected PrototypeModel clone() throws CloneNotSupportedException {
        return (PrototypeModel) super.clone();
    }

}

    